package service;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;

import util.FileLoader;

public class GlobalConfiguration {
	
	private final Logger logger = Logger.getLogger(GlobalConfiguration.class);
	
	private static final String filename = "global.conf";
	
	private static GlobalConfiguration config = null;
	private static Properties properties = null;
	
	private GlobalConfiguration() {
		try {
			properties = FileLoader.LoadProperties(filename);
		} catch (FileNotFoundException e) {
			logger.error("{}", e);
		} catch (IOException e) {
			logger.error("{}", e);
		}
	}
	
	public static GlobalConfiguration getInstance(){
		if(null == config){
			config = new GlobalConfiguration();
		}
		return config;
	}
	
	public String get(String key){
		return properties.getProperty(key);
	}
	
	public String get(String key, String defaultValue){
		return properties.getProperty(key, defaultValue);
	}
	
}
